import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { BudgetSubjectVO, BudgetSubjectForm, BudgetSubjectQuery } from "@/api/budget/budgetSubject/types";

/**
 * 查询科目管理列表
 * @param query
 * @returns {*}
 */

export const listBudgetSubject = (query?: BudgetSubjectQuery): AxiosPromise<BudgetSubjectVO[]> => {
  return request({
    url: "/budget/subject/getListNew",
    method: "post",
    data: query
  });
};

/**
 * 查询科目管理详细
 * @param id
 */
export const getBudgetSubject = (id: string | number): AxiosPromise<BudgetSubjectVO> => {
  return request({
    url: "/budget/subject/" + id,
    method: "get"
  });
};

/**
 * 新增科目管理
 * @param data
 */
export const addBudgetSubject = (data: BudgetSubjectForm) => {
  return request({
    url: "/budget/subject",
    method: "post",
    data: data
  });
};

/**
 * 修改科目管理
 * @param data
 */
export const updateBudgetSubject = (data: BudgetSubjectForm) => {
  return request({
    url: "/budget/subject",
    method: "put",
    data: data
  });
};

/**
 * 删除科目管理
 * @param id
 */
export const delBudgetSubject = (id: number | string) => {
  return request({
    url: "/budget/subject/" + id,
    method: "delete"
  });
};

export const getListSubject = () => {
  return request({
    url: "/budget/subject/getSubjectList",
    method: "get"
  });
};
